#include <iostream>
#include <signal.h>
#include <unistd.h>

volatile int flag = 0;

void handler(int signum)
{
    std::cout << "Changing the value of the global variable flag, " << flag << " -> " << 1 << std::endl;
    flag = 1;
}

int main()
{

    signal(2, handler);

    while (flag == 0);
    std::cout << "Process quit normally!" << std::endl;

    return 0;
}